/*
 * @Author: chunlai
 * @Date: 2024-09-04 14:28:38
 * @LastEditTime: 2025-04-11 11:01:59
 * @LastEditors: minsheng_insurance_agency_zhoucl
 * @FilePath: \0.newInsure\src\mixins\sign.js
 * @Description: 多被保人签名
 */
export const multiBbrSignMinxin = {
  computed: {
    tbrSignShow() {
      let res = true;
      if (this.shareType) {
        res = this.shareType === "1";
      }
      return res;
    },
    dlrSignShow() {
      let res = true;
      if (this.shareType) {
        res = this.shareType === "3";
      }
      // 百年仅有可回溯需要代理人签字
      if (this.compEngName === "bainian") {
        const provns = this.selfInsuredRegions || [];
        res = provns.includes(this.tbrPrvinCapital);
      }
      if (this.dlrDontSign) {
        res = false;
      }
      return res;
    },
    dlrSignDone() {
      let res = false;
      if (this.dlrSignImg) {
        res = true;
      }
      if (this.dlrDontSign) {
        res = true;
      }
      return res;
    },
  },
  methods: {
    bbrItemShow(item) {
      let res = true;
      if (this.shareType) {
        res = this.shareType === "2";
      } else {
        res = item.relationToAppnt != "4";
      }
      return res;
    },
    bbrNameLabel(item, index) {
      const idx = this.bbrDataList.length > 1 ? index + 1 : "";
      let res = `被保险人${idx}`;
      if (this.$GlobalFuns.isMinorBaby(item) && item.guardianName) {
        res = `被保险人${idx}(法定监护人)`;
      }
      return res;
    },
    bbrNameValue(item) {
      let res = item.name;
      if (this.$GlobalFuns.isMinorBaby(item) && item.guardianName) {
        res = item.guardianName;
      }
      return res;
    },
    // 未成年提示信息
    minorWarn(item) {
      return this.$GlobalFuns.isMinorBaby(item);
    },
    signDoneCheck() {
      let res = true;
      if (this.tbrSignShow && !this.tbrSignImg) {
        res = false;
      }
      if (this.dlrSignShow && !this.dlrSignDone) {
        res = false;
      }
      // 多被保人
      const len = this.bbrDataList.length;
      for (let s = 0; s < len; s++) {
        const bitem = this.bbrDataList[s];
        if (this.bbrItemShow(bitem) && !bitem.signImg) {
          res = false;
          break;
        }
      }
      // console.log("done----", res);
      this.$emit("change", res);
    },
  },
};
